package com.longqin.wechat.mapper;

import org.apache.ibatis.annotations.Param;

import com.longqin.wechat.entity.User;
import com.longqin.wechat.entity.WxUserInfo;
import com.longqin.wechat.entity.WxUserKey;

public interface WxUserMapper {

    int insert(WxUserKey record);

    int insertSelective(WxUserKey record);
    
    /**
     * @Description: 根据openid查询账户信息
     * 
     */
    User selectUserInfoByOpenId(@Param("openId")String openId);
    
    /**
     * @Description: 通过账号名查询账号信息
     * 
     */
    User selectByUserName(@Param("userName")String userName);
    
    /**
     * @Description: 插入用户id和openid，不存在则不插入，存在更新
     * @param userId
     * @param openId
     * 
     */
    int insertIgnoreUserOpenId(@Param("userId")int userId, @Param("openId")String openId,
    		@Param("unionId")String unionId, @Param("nickName")String nickName, @Param("headimgurl")String headimgurl);
    
    /**
     * @Description: 存在则删除
     * @param userId
     * @param openId
     * 
     */
    int deleteByUserIdAndOpenId(@Param("userId")int userId, @Param("openId")String openId);
    
    
    /**
     * @Description: 根据openid查询用户微信信息
     * 
     */
    WxUserInfo selectWxInfoByOpenId(@Param("openId")String openId);
    
    /**
     * @Description: 更新客户微信昵称和头像
     * @param nickName
     * @param headimgurl
     * @param openId
     * 
     */
    int updateWxInfoByOpenId(@Param("nickName")String nickName, @Param("headimgurl")String headimgurl, @Param("openId")String openId);
}